package com.blueberry.quiz_master.exception;

import com.blueberry.quiz_master.common.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    /**
     * 处理所有业务参数相关的异常 (例如敏感词校验失败)
     */
    @ExceptionHandler(IllegalArgumentException.class)
    public Result<?> handleIllegalArgumentException(IllegalArgumentException e) {
        // 返回状态码 400 (Bad Request) 或 500，并带上详细的错误信息
        return Result.fail(400, e.getMessage());
    }
}
